<template>
  <div id="Boss_Detail">
    <!-- 返回导航条 -->
    <router-view name="header" fixed :component_name="Boss_Detail"></router-view>
    <div id="Boss_Detail_name">所有文章信息:</div>
  
    <!-- 项目组 -->
    <div v-if="loadingData">
      <mt-spinner type="double-bounce" class="loadingData"></mt-spinner>
    </div>
  <div v-else="loadingData">
    <div v-for="item in list" class="media-1-1">
      <mt-header :title="item.title" id="cell_1">
        <mt-button slot="left" @click="deleteDetail(item._id)">删除</mt-button>
        <mt-button slot="right" @click="showDetail(item._id)">详细</mt-button>
      </mt-header>
      <div id="item_time">
        {{item.created_at}}
      </div>
      <div id="item_poster">
        发布者：{{item.poster}}
      </div>
    </div>
</div>
  </div>
</template>

<script>
import Vue from 'vue'

export default {
  name: 'Boss_Detail',
  data() {
    return {
      value1: false,
      list: [],
      title: '',
      poster: '',
      rating: null,
      introduction: '',
      message_id: '',
      loadingData:true,
    }
  },
  created() {
    // 获取信息渲染列表
    this.$store.dispatch({
      type: 'getMessage',
      callback: (result) => {
        this.list = result.data;
        this.loadingData = false;
      }
    });
  },
  methods: {

    showDetail(_id) {
      this.$router.push(`/Boss_item/${_id}`)
    },
    //删除信息（并将_id传值个给state）
    deleteDetail(_id) {
      this.$store.dispatch("deletes", _id)
        .then(() => {
          this.truedeleteDetail();
          this.updateMessage();
        })

    },
    //调用store中的actions删除信息
    truedeleteDetail() {
      this.$store.dispatch("deleteMessage")
    },
    //更新信息的方法（添加、删除信息后重新读取后台信息）
    updateMessage() {
      this.$store.dispatch({
        type: 'getMessage',
        callback: (result) => {
          this.list = result.data;
        }
      });
    },

  }
}

</script>


<style>
#cell_1 {
 margin-right: auto;
  margin-left: auto;
  font-size: 12px;
  width: 90%;
  height: 40%;
  border-radius: 20px 20px;
  background-color: transparent !important;
  color: rgba(255, 255, 255, 1) !important;
  background-color: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid black !important;
}

#Boss_Detail_name {
  color: gray;
  font-size: 14px;
  text-align: left;
  margin-bottom: 30px;
}

#item_poster {
  color: rgba(0, 0, 0, 0.7);
  margin-top: 10px;
  text-align: right;
  font-size: 13px;
}

#item_time {
  padding-left: 20px;
  margin-top: 10px;
  color: rgba(0, 0, 0, 0.7);
  float: left;
  text-align: left;
  font-size: 13px;
}

.media-1-1 {
 background: linear-gradient(to right, rgba(144, 144, 144, 0.2), rgba(144, 144, 144, 0.7));
  /*background-color: rgba(126, 181, 255, 1);*/
  margin-bottom: 20px;
  border-top-left-radius: 0px;
  border-top-right-radius: 60px;
  border-bottom-right-radius: 60px;
  border-bottom-left-radius: 60px;
  /*border-radius: 0px 60px x;*/
  height: 50px;
  /*border: 1px solid rgba(168, 40, 53, 1);*/
  padding-left: 10px;
  padding-right: 20px;
  padding-top: 12px;
}
</style>
